package com.liuyk.commonlib.network;

import java.util.List;
import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.HeaderMap;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;
import rx.Observable;

/**
 * 请求方法
 * <p>
 * Created by liuyakui on 2020/6/24
 */
public interface ApiInterface {

    @Multipart
    @POST()
    Observable<ResponseBody> postFile(@Url String url, @Part MultipartBody.Part part, @HeaderMap Map<String, String> header);

    @Multipart
    @POST()
    Observable<ResponseBody> postFiles(@Url String url, @Part List<MultipartBody.Part> parts, @HeaderMap Map<String, String> header);

    @POST()
    Observable<ResponseBody> post(@Url String url, @Body RequestBody body, @HeaderMap Map<String, String> header);

    @GET()
    Observable<ResponseBody> get(@Url String url, @QueryMap Map<String, String> map, @HeaderMap Map<String, String> header);

    @Streaming
    @GET
    Observable<ResponseBody> download(@Url String url);

    @Streaming
    @GET
    Observable<ResponseBody> download(@Url String url, @Header("Range") String range);

    @DELETE()
    Observable<ResponseBody> delete(@Url String url, @HeaderMap Map<String, String> header);

    @PUT()
    Observable<ResponseBody> put(@Url String url, @Body RequestBody body, @HeaderMap Map<String, String> header);

}
